home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Hardware / BlizKick / Modules / FixMath404.ASM < prev    next >
Encoding:
Assembly Source File  |  2002-03-13  |  3.7 KB  |  163 lines

  1. ; FILE: Source:modules/FixMath404.ASM          REV: 14 --- Fix V40.4 math library
  2.  
  3. ;
  4. ; Fix mathieeesingbas 40.4 -Module
  5. ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. ; This patch module will fix mathieeesingbas.library V40.4 bug in functions
  7. ; IEEESPMul() and IEEESPDiv() [this bug occurs if you don't have 68881 or
  8. ; 68882 FPU].
  9. ;
  10. ; V1.1 - 13th Dec 2000
  11. ; Made it possible to patch mathieeesingbas.library that is fully or
  12. ; partially inside extresbuf. Added a check for 40.70 A3000 rom that
  13. ; doesn't have this bug, since it is guaranteed to have FPU.
  14. ;
  15. ; Written by Harry Sintonen.
  16. ; This source code is Public Domain.
  17. ;
  18.  
  19.     incdir    "include:"
  20.     include    "blizkickmodule.i"    ; Some required...
  21.  
  22.  
  23.     SECTION    PATCH,CODE
  24. _DUMMY_LABEL
  25.     BK_PTC
  26.  
  27. ; Code is run with following incoming parameters:
  28. ;
  29. ; a0=ptr to ROM start (buffer)    eg. $1DE087B8
  30. ; a1=ptr to ROM start (ROM)    eg. $00F80000 (do *not* access!)
  31. ; d0=ROM lenght in bytes    eg. $00080000
  32. ; a2=ptr to _FindResident routine (will search ROM buffer for resident tag):
  33. ;    CALL: jsr (a2)
  34. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to resident name
  35. ;     OUT: d0=ptr to resident (buf) or NULL
  36. ; a3=ptr to _InstallModule routine (can be used to plant a "module"):
  37. ;    CALL: jsr (a3)
  38. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to module, d6=dosbase
  39. ;     OUT: d0=success
  40. ; a4=ptr to _Printf routine (will dump some silly things (errormsg?) to stdout ;-)
  41. ;    CALL: jsr (a4)
  42. ;      IN: a0=FmtString, a1=Array (may be 0), d6=dosbase
  43. ;     OUT: -
  44. ; d6=dosbase, a6=execbase
  45. ;
  46. ; Code should return:
  47. ;
  48. ; d0=true if succeeded, false if failed.
  49. ; d1-d7/a0-a6 can be trashed. a7 *must* be preserved! ;-)
  50.  
  51.     moveq    #0,d7
  52.  
  53.     cmp.w    #40,($C,a0)        ; Requires KS V40+
  54.     blo    .exit
  55.  
  56.     lea    (regs,pc),a5
  57.     movem.l    d0/a0-a1,(a5)
  58.  
  59.     lea    (_mname,pc),a1        ; _FindResident
  60.     jsr    (a2)
  61.     tst.l    d0
  62.     beq.b    .exit
  63.     move.l    d0,a2            ; a2=mathlib resident
  64.  
  65.     cmp.b    #40,(RT_VERSION,a2)    ; V40
  66.     bne.b    .exit
  67.     cmp.b    #RTF_COLDSTART,(RT_FLAGS,a2) ; Coldstart
  68.     bne.b    .exit
  69.     move.l    (RT_IDSTRING,a2),d0
  70.     beq.b    .exit
  71.     bsr.b    buffer
  72.     move.l    d0,a5            ; a5=ptr in buffer
  73.  
  74. .find    cmp.b    #'0',(a5)+        ; 40.4
  75.     bne.b    .find
  76.     addq.l    #1,a5
  77.     cmp.b    #'4',(a5)+
  78.     bne.b    .exit
  79.     cmp.b    #' ',(a5)
  80.     bne.b    .exit
  81.  
  82.     move.l    (RT_INIT,a2),d0        ; Test RT_INIT
  83.     beq.b    .exit
  84.     bsr.b    buffer
  85.     move.l    d0,a2            ; a2=ptr in buffer
  86.  
  87.  
  88.     moveq    #32/2,d1
  89.     move.w    #$41F9,d0        ; Find first "lea ABS,a0"
  90. .find2    subq.l    #1,d1
  91.     beq.b    .exit
  92.     cmp.w    (a2)+,d0
  93.     bne.b    .find2
  94.  
  95. .find3    subq.l    #1,d1            ; Find second "lea ABS,a0"
  96.     beq.b    .nobug
  97.     cmp.w    (a2)+,d0
  98.     bne.b    .find3
  99.  
  100.     move.l    (a2),d0            ; lea abs address...
  101.     bsr.b    buffer
  102.     move.l    d0,a2            ; ...in buffer address
  103.  
  104.     move.w    (a2)+,d0        ; Test for $FFFF
  105.     addq.w    #1,d0
  106.     bne.b    .exit
  107.  
  108.     lea    (12*2,a2),a2        ; 13th & 14th function
  109.     cmp.l    #$001A001C,(a2)        ; Check for invalid
  110.     bne.b    .aok            ; Already ok!
  111.     move.l    #$063606A0,(a2)        ; Stuff correct!
  112.     moveq    #1,d7
  113.  
  114. .exit    move.l    d7,d0            ; Valid counter?
  115.     bne.b    .xit
  116.     lea    (_error1,pc),a0        ; a0=fmt
  117.     pea    (_mname,pc)
  118.     move.l    sp,a1            ; a1=array
  119.     jsr    (a4)            ; Call _Printf
  120.     addq.l    #4,sp
  121.     moveq    #0,d0            ; Return fail
  122. .xit    rts
  123.  
  124. .aok    lea    (_error2,pc),a0
  125. .print    jsr    (a4)            ; Call _Printf
  126.     moveq    #1,d0
  127.     rts
  128.  
  129. .nobug    lea    (_nobug,pc),a0
  130.     bra.b    .print
  131.  
  132.  
  133. buffer    ;test if inside rom bounds?
  134.     move.l    (rom_log,pc),d1
  135.     cmp.l    d1,d0
  136.     blo.b    .nofix
  137.     add.l    (rom_size,pc),d1
  138.     cmp.l    d1,d0
  139.     bhs.b    .nofix
  140.     ; inside rom, so generate ram buffer address
  141.     sub.l    (rom_log,pc),d0        -$f80000
  142.     add.l    (rom_phys,pc),d0    +buffer
  143. .nofix    rts
  144.  
  145.  
  146.  
  147. _mname    dc.b    'mathieeesingbas.library',0
  148.  
  149. _error1    dc.b    'FixMath404: This patch requires V40 ROM with %s V40.4!',10,0
  150. _error2    dc.b    'FixMath404: Already OK!',10,0
  151. _nobug    dc.b    'FixMath404: This ROM doesn''t have the bug',10,0
  152.  
  153.  
  154.     CNOP    0,2
  155. regs
  156. rom_size    ds.l    1
  157. rom_phys    ds.l    1
  158. rom_log    ds.l    1
  159.  
  160.     SECTION    VERSION,DATA
  161.  
  162.     dc.b    '$VER: FixMath404_PATCH 1.1 (13.12.00)',0
  163.